#pragma once

#include "I_GlobalFunction.h"
#include "map"
#include "string"

class CGlobalFunctionImpl : public I_GlobalFunction
{
public:
	CGlobalFunctionImpl();
	~CGlobalFunctionImpl();

// GlobalValue
public:
	virtual BOOL Init(PGFINIT p);

	virtual BOOL GetGlobalValue(LPCSTR szKey, PGFSTRING pszValue);
	virtual void SetGlobalValue(LPCSTR szKey, LPCWSTR szValue);
	virtual void DelGlobalValue(LPCSTR szKey);
	virtual void SaveGlobalValue();

// Session
public:
	virtual HGFINTERNETSESSION CreateInternetSession();
	virtual void DestroyInternetSession(HGFINTERNETSESSION hSession);
	virtual BOOL CreateDispatchAndAttachInternetSession(HGFINTERNETSESSION hSession, IDispatch** ppDisp);
	virtual HGFINTERNETSESSION GetInternetSessionFromDispatch (IDispatch* pSession);
	
// OpenUrl
public:
	virtual BOOL OpenUrl(PGFOPENURL p);
	virtual BOOL AddLog(LPCWSTR lpszLog);

private:
	// GlobalValue
	void _GVLoadFile();
	void _GVSaveFile();
	CString _GVGetFileName() const;

	typedef std::map<std::string, std::wstring> MAP_KEY_VALUE;
	MAP_KEY_VALUE m_map;

	GFINIT m_init;
};